package com.idea.zd.sys.train.collection;

import java.util.Stack;

public class StackTest {

    public static void main(String [] args){
        /**
         * 后进先出 LIFO
         */
        Stack stack = new Stack();
        //添加
        stack.push("one");
        stack.push("two");
        stack.push("three");
        System.out.println(stack.size());

        //拿出第一个不出栈
        System.out.println(stack.peek());
        System.out.println(stack.size());

        //拿出并出栈
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.size());


    }
}
